const m = new WeakMap();
// WeakMap的键必须是一个对象，是个弱映射表
// (method) WeakMap<object, any>.set(key: object, value: any): WeakMap<object, any>
// Adds a new element with a specified key and value.
// @param key — Must be an object or symbol.

// m.set('a', 2)
// console.log(m); //weakMap.js:7 Uncaught TypeError: Invalid value used as weak map key

const a = { a: 1 };
m.set(a, a);
console.log(m.get({ a: 1 }), m.get(a)); // undefined { a: 1 }
